package nowember.test_11_2;

import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] strs = str.split(",");
        int n = strs.length;
        int j = 0;
        String s = strs[j];
        s = new StringBuffer(s).reverse().toString();
        n--;
        for (int i = 0; i < n; i++) {
            String t = strs[++j];
            t = new StringBuffer(t).reverse().toString();
            s = common(s,t);
        }
        s = new StringBuffer(s).reverse().toString();
        if(s.length() == 0) {
            System.out.println("xyz");
        } else {
            System.out.println(s);
        }
    }
    public static String common(String s, String t) {
        int most = 0;
        int len = Math.min(s.length(), t.length());
        for(int i = 0; i < len; i++) {
            if(s.charAt(i) == t.charAt(i)) {
                most++;
            } else {
                break;
            }
        }
        return s.substring(0, most);
    }
}
